|
|
|
|
|
|
|
'Declare standard variables
Dim cDBName as String
Dim cTable as String
'Initialize variables
cDBName = "c:\DATAS\ACCTPAY.MDB"
cTable = "Vendors"
'Set values
set Dat = OpenDatabase(cDBName)
Set rsSnap = Dat.OpenRecordset(cTable,dbOpenSnapshot)
End Sub |
|
|
|
|
|
|
|
|
3. You use the Table data object because it gives you instant information when records are changed. Your code might look like this: |
|
|
|
|
|
|
|
|
Sub Form_Load()
'Create a database and table object
Dim Dat as Database
Dim tblObject as Recordset
'Declare standard variables
Dim cDBName as String
Dim cTable as String
'Initialize variables
cDBName = "c:\DATAS\ACCTPAY.MDB"
cTable = "Vendors"
'Set values
set Dat = OpenDatabase(cDBName)
Set tblObject = Dat.OpenRecordset(cTable,dbOpenTable)
End Sub |
|
|
|
|
|
|
|
|
1. You can establish a database for a data control by setting the DatabaseName property of the data control to the name of the database (including the path), or to a defined variable that points to the database. For example, to attach the data control Data1 to a Microsoft Access database C:\DATAPATH\XYZ.MDB, you can enter the following: |
|
|
|
|
|
|
|
|
Data1.DatabaseName = "C:\DATAPATH\XYZ.MDB" |
|
|
|
|
|
|
|
|
2. You use the RecordSource property to establish the name of a table for a data control in Visual Basic. For example, to set the data control Data1 to a table of vendors in an accounts payable application, you can type the following: |
|
|
|
|
|
|
|
|
Data1.RecordSource = "Vendors" |
|
|
|
|
|